<?php
/**
 * Created by PhpStorm.
 * User: wangan
 * Date: 2018/7/31
 * Time: 9:50
 */

namespace app\commom\lib;


class Predis
{
    private $redis;
    private static $_instance = null;

    public static function getInstance(){
        if (!self::$_instance){
            self::$_instance = new self();
        }
        return self::$_instance;
    }

    public function getRedis(){
        return $this->redis;
    }

    private function __construct()
    {
        $this->redis = new \Redis();

        $host = config('redis.host');
        $port = config('redis.port');
        $passwd = config('redis.passwd');
        $timeOut = config('redis.timeOut');

        $this->redis->connect($host, $port, $timeOut);
        $this->redis->auth($passwd);
    }

    private function __clone(){

    }

    public function __call($name, $arguments)
    {
        // TODO: Implement __call() method.
        echo $name;
        print_r($arguments);
    }

    public function sadd($key, $val){
        return $this->redis->sAdd($key, $val);
    }

    public function srem($key, $val){
        return $this->redis->sRem($key, $val);
    }

    public function smembers($key){
        return $this->redis->sMembers($key);
    }


}